package com.xy.blog.core.springmvc.result.base.data;

import com.xy.blog.core.springmvc.result.base.BaseResult;
import lombok.Data;

/**
 * @author zanhonglei
 * @version V1.0
 * @Description:
 * @date 2019/11/2 14:41
 */
@Data
public class RestResult<T> extends BaseResult<T> {


    private RestResult(T t, String code,String message,boolean success){
        this.data = t;
        this.code = code;
        this.message = message;
        this.success = success;
    }

    /**
     * 成功返回结果集
     * @param data
     * @return
     */
    public static RestResult data(Object data){
       return new RestResult<>(data, "0", "",true);
    }

    /**
     * 成功
     * @return
     */
    public static RestResult success(){
        return new RestResult<>("", "0", "",true);
    }

    /**
     * 失败
     * @param code
     * @param message
     * @return
     */
    public static RestResult error(String code,String message){
        return new RestResult<>("", code, message,false);
    }

    /**
     * 失败
     * @param code
     * @return
     */
    public static RestResult error(String code){
        return new RestResult<>("", code, "",false);
    }


}

